package paket;

import java.io.IOException;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import smarthouse.Smarthouse;
import smarthouse.SmarthouseXMLEnc;
import swing.SwingGui;

/**
 * Servlet implementation class TestServlet
 */
public class FetchStructure extends HttpServlet {
	private static final long serialVersionUID = 1L;
	SmarthouseXMLEnc encoder;
       
    /**
     * @see HttpServlet#HttpServlet()
     */
    public FetchStructure() {
        super();
        Smarthouse.getInstance();
        encoder = new SmarthouseXMLEnc();
    }

	/**
	 * @see HttpServlet#doGet(HttpServletRequest request, HttpServletResponse response)
	 */
	protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
		//response.getWriter().
		response.reset();
		response.getWriter().write(encoder.encode(Smarthouse.getInstance().getDevicesByRoom()));
		response.flushBuffer();
		//response.getWriter().flush();
	}

	/**
	 * @see HttpServlet#doPost(HttpServletRequest request, HttpServletResponse response)
	 */
	protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
		// TODO Auto-generated method stub
	}

}
